layui.use(['form', 'table'], function () {
    let $ = layui.jquery,
        form = layui.form,
        table = layui.table,
        layer=layui.layer;
    //form.render();
    $.ajaxSetup({
        // 发送cookie
        xhrFields: {
            withCredentials: true
        },
        // 请求发送前
        beforeSend: function () {
            // 发送请求前，可以对data、url等处理
        },
        // 请求返回
        complete: function () {
            // 返回数据，根据数据调转页面等
        }
    });
    $("#remove").click(function () {
        let index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    });

    $("#affirm").click(function () {
        let deviceid = $("#deviceid").val();
        let name = $("#versionName").val();
        if(deviceid === '') {//修改所以版本
            $.ajax({
                url: devUrl + '/api/device/admin/deviceVersionUpgrade',
                data: {name:name},
                dataType:"json",
                type: "post",
                success: function (result) {
                    alert(result.msg);
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            })
        } else {//修改单个版本
            $.ajax({
                url: devUrl + '/api/device/admin/deviceVersionUpgrade',
                data: {
                    deviceid:deviceid,
                    name:name},
                dataType:"json",
                type: "post",
                success: function (result) {
                    alert(result.msg);
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            })
        }
    });
});